<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends Action {
    public function index(){
        $app = M('app')->select();
        $this->assign('app',$app)->display();
    }
    //异步发送处理
    public function handle(){
        if(!IS_AJAX){
            halt('页面不存在');
        }
        $data = array(
          'username'=>I('username'),
          'content'=>I('content'),
          'time'=>time(),
        );

        if(M('app')->data($data)->add()){
            $data['content'] = replace_pic($data['content']);
            $data['time'] = date('Y-m-d H:i',$data['time']);
            $data['status'] = 1;
            $this->ajaxReturn($data,'json');
        }
        else{
//            echo json_encode(array('status'=>0));
            $this->ajaxReturn(array('status'=>0),'json');
        }
    }
}